 <include file="./head" />
<include file="./logo" />
<div class="page-viewport">
<div class="page-content">   
<div class="doc_info doc_mg" style="margin-top:1em;">
<h3>文章收益报告</h3>
<blockquote>
<p>今日文章转发收益 ￥{:get_erwei($jinri['price'])}</p>
</blockquote>
<blockquote>
<p>昨日文章转发收益 ￥{:get_erwei($zuori['price'])}</p>
</blockquote>
<blockquote>
<p>文章转发总收益 ￥{:get_erwei($user_info['balance']+$user_info['paid'])}</p>
</blockquote>
</div>
<div class="doc_info" id="newsViewDiv" style="display: block;margin-top:1em;">
    <h3>24小时内收益详情报告</h3>
    <table class="table table-striped">
        <thead>
            <tr>
                <th width="60%" style="text-align:center;">标题</th>
                <th width="20%" style="text-align:center;">阅读</th>
                <th width="20%" style="text-align:center;">收益</th>
            </tr>
        </thead>

        <tbody id="h24data">
         <img src='/Public/user/loading.gif'  class="loading" /> 
        </tbody>
    </table>
    
 <div id="page"></div>
</div>
</div>
</div>
</div>
<div class="bottom_line"></div>
 <include file="./foot" />
 <style type="text/css">
 #h24data td{ text-align: center;}
 </style>
 <script type="text/javascript">
            var page_cur = 1; //当前页
            var total_num, page_size, page_total_num;//总记录数,每页条数,总页数
            function getData(page) { //获取当前页数据
                $.ajax({
                    type: 'GET',
                    url: '<?php echo U("/User/Share/h24"); ?>',
                    data: {'page': page - 1},
                    dataType: 'json',
                    success: function(json) {
                        $("#h24data").empty();
                        $(".loading").hide();
                        total_num = json.total_num;//总记录数
                        page_size = json.page_size;//每页数量
                        page_cur = page;//当前页
                        page_total_num = json.page_total_num;//总页数
                        var li = "<tr>";
                        var list = json.list;
                        $.each(list, function(index, array) { //遍历返回json
                            li += "<td style='overflow:hidden'>"+array['news']['title'].substr(0,12)+"</td><td>"+ array['count']+"</td><td>"+ (array['count']*0.06).toFixed(2)+"</td></tr>";
                        });
                        $("#h24data").append(li);
                    },
                    beforeSend:function(){
                         $(".loading").show();
                    },
                    complete: function() {
                       getPageBar();//js生成分页，可用程序代替
                    },
                    error: function() {
                        $("#h24data").html("系统超时,请稍等在操作!");
                    }
                });
            }


            $(function() {
                getData(1);//默认第一页
                $("#page a").live('click', function() { //live 向未来的元素添加事件处理器,不可用bind
                    var page = $(this).attr("data-page");//获取当前页
                    getData(page)
                });  
            });

           function getPageBar() { //js生成分页
                if (page_cur > page_total_num)
                    page_cur = page_total_num;//当前页大于最大页数
                if (page_cur < 1)
                    page_cur = 1;//当前页小于1
                page_str = "";//"<span>共" + total_num + "条</span><span>" + page_cur + "/" + page_total_num + "</span>";
                if (page_cur <= 1) {
                    page_str += "<span class='home'>首页</span>";
                } else {
                    page_str += "<span><a href='javascript:void(0)' data-page='" + (page_cur - 1) + "'>上一页</a></span>";
                }
                if (page_cur >= page_total_num || page_total_num==0) { 
                    page_str += "<span class='home'>尾页</span>";
                } else {
                    page_str += "<span><a href='javascript:void(0)' data-page='" + (parseInt(page_cur) + 1) + "'>下一页</a></span>";
                }
                if(total_num>6){
                    $("#page").html(page_str);
                }
                
            }
        </script>
</body>
</html>